An essential semiconductor device is semiconductor memory, such as a random access memory (RAM) device. A RAM allows a memory circuit to execute both read and write operations on its memory cells. Typical examples of RAM devices include dynamic random access memory (DRAM) and static random access memory (SRAM).
Another form of memory is the content addressable memory (CAM) device. A CAM is a memory device that accelerates any application requiring fast searches of a database, list, or pattern. CAMs provide benefits over other memory search algorithms by simultaneously comparing the desired information (i.e., data in the comparand register) against the entire list of pre-stored entries. CAM devices are frequently employed in network equipment, and more specifically, in network routers or switches, where frequently at least a portion of a network address must be searched against a database in order to determine how to further route a packet of data.
There are two types of searches which are of interest, namely a search for the exact match and the partial match search. In the exact match search, an entry stored in the CAM will match the data sample only if the data sample and the entry match bit for bit. In a partial match search, the search may be conducted on only a subset of bits in the word. That is, the CAM cells are permitted to specify a third “don't care” state in addition to the logical “0” and “1” states. When a partial match search is conducted, CAM cells will match a data sample as long as each bit in the entry set at a logical “0” or “1” states match the corresponding portion of the data sample. CAMs which support only exact match circuits are generally known as binary CAMs, while CAMs which also support partial match searches are generally known as ternary CAMs.
In order to perform a memory search, CAMs are organized differently than other memory devices (e.g., DRAM and SRAM). For example, data is stored in a RAM in a particular location, called an address. During a memory access, the user supplies an address and reads or gets data stored at the specified address. In a CAM, however, data is stored in locations in a somewhat random fashion. The locations can be selected by an address bus, or the data can be written into the first empty memory location. Every location has a plurality of status bits that keep track of status information, for example, whether the location is storing valid information.
Once information has been stored in the CAM entries (each entry containing a plurality of CAM cells), it can be found by writing a search expression to a comparand register of the CAM. Each CAM entry is associated with a local match detection circuit, which returns a “match” or “no match” indication based on a comparison between the content of the comparand register and the local CAM entry. If at least one local match detection circuit returns a “match” indication, the search is successful and the address of the CAM entry matching the search expression may also be output by the CAM. If multiple CAM cells return a “match” indication, the CAM may have a priority encoder and only output the address of the highest priority matching CAM entry. Thus, in contrast to conventional memory devices, in a CAM the user supplies the data and gets back an address if there is at least one match found in the CAM.
In many network devices, there is a need to gather statistics relating to the operation of the network device and/or the network traffic processed by the device. For example, a router may compile statistics relating to the amount of traffic processed over a given period of time, perhaps organized or divided into subcategories (e.g., by source and/or destination addresses, packet size distribution, time of day, etc.) The router can be programmed with an expected baseline for the statistics it gathers and the router could also alert a network administrator if the statistics gathered by the router deviate beyond a predetermined threshold from the norm. Such an ability may alert an network administrator to possible configuration errors, malfunctions, or attacks. Traditionally, network statistics are maintained using dedicated circuits and/or software routines which gather and maintain network statistics in reserved memory locations and/or registers. The use of dedicated circuits and/or software routines is not efficient and may not be sufficiently flexible. Accordingly, there is a desire and need for an efficient and flexible method and apparatus to gather statistics.